Imports Microsoft.VisualBasic
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Imports System.Data
Imports DataAccesGenerales
Imports DataAcces

Public Class DataAccesCapt_PermisoMovimiento
  Private Const consTimeOut As Integer = 0 
  
  ''' <summary>
  ''' Funcion para Insertar un regristro en la tabla Capt_PermisoMovimiento
  ''' </summary>
  Public Function Capt_PermisoMovimiento_InsertarModificar(pnidDocumento As Long, pnidAvisoArribo As Long, pnidBuque As Long, pbandera As String, ppuerto_registro As String, ptoneladas_Brutas As Long, ptoneladas_Netas As Long, pcapitan As String, ppuerto_procedencia As String, pdes_movimiento As String, pIMO As String, peslora As Long, pmanga As Long, pcalado_Proa As Long, pcalado_Popa As Long, pfecha_Movimiento As Date, pnombre_Buque As String, pnaviera As String, pmuelle_Origen As String, pmuelle_Destino As String, pemp_Lanchas As String, pnum_Lanchas As Long, ppuerto_Reg As String, pcodigo_Llamada As String, pnum_Oficial As Integer, pnum_Omi As Integer, pcolocacion_Quilla As Integer, ppuesto_Marcha As Integer, pTRB As Long, pTRN As Long, pconstructores As String, pclase As String, pmotor As String, ppropietarios As String, poperador As String, ppuntal As Long, peslora_Total As Long, peslora_Perpendiculares As Long, paltura As Long, pluz As Long, ppuerto_Destino As String, pemp_Amarradores As String, pfolio_Permiso_Entrada As String, ptipo_Buque As String, ptipo_Carga As String, pcodigo_Pbip As String, pcolor_Casco As String, pemp_Remolcadores As String, pnum_Remolcadores As Integer, pemp_Pilotos As String, pnum_Pilotos As Integer, pnum_Amarradores As Integer, ppeso_Muerto As Long, pcalado_Construccion As Long, ptipo_Cabo As String) As Byte
    Dim pTransaccion As Byte = 0
    Dim mensaje As String = String.Empty
    Try
      Using oraConnection As New Oracle.DataAccess.Client.OracleConnection(ConfigurationManager.ConnectionStrings("EDIV2DESOraClient").ConnectionString)
        Using oraCommandDocumentos As New Oracle.DataAccess.Client.OracleCommand()
          oraCommandDocumentos.Connection = oraConnection
          oraCommandDocumentos.CommandTimeout = consTimeOut
          oraCommandDocumentos.CommandType = CommandType.StoredProcedure
          oraCommandDocumentos.CommandText = "EDIV2.?NomPaquete.Capt_PermisoMovimientoInsertarModificar" 
          oraCommandDocumentos.Parameters.Add("pnidDocumento", pnidDocumento)
          oraCommandDocumentos.Parameters.Add("pnidAvisoArribo", pnidAvisoArribo)
          oraCommandDocumentos.Parameters.Add("pnidBuque", pnidBuque)
          oraCommandDocumentos.Parameters.Add("pbandera", pbandera)
          oraCommandDocumentos.Parameters.Add("ppuerto_registro", ppuerto_registro)
          oraCommandDocumentos.Parameters.Add("ptoneladas_Brutas", ptoneladas_Brutas)
          oraCommandDocumentos.Parameters.Add("ptoneladas_Netas", ptoneladas_Netas)
          oraCommandDocumentos.Parameters.Add("pcapitan", pcapitan)
          oraCommandDocumentos.Parameters.Add("ppuerto_procedencia", ppuerto_procedencia)
          oraCommandDocumentos.Parameters.Add("pdes_movimiento", pdes_movimiento)
          oraCommandDocumentos.Parameters.Add("pIMO", pIMO)
          oraCommandDocumentos.Parameters.Add("peslora", peslora)
          oraCommandDocumentos.Parameters.Add("pmanga", pmanga)
          oraCommandDocumentos.Parameters.Add("pcalado_Proa", pcalado_Proa)
          oraCommandDocumentos.Parameters.Add("pcalado_Popa", pcalado_Popa)
          oraCommandDocumentos.Parameters.Add("pfecha_Movimiento", pfecha_Movimiento)
          oraCommandDocumentos.Parameters.Add("pnombre_Buque", pnombre_Buque)
          oraCommandDocumentos.Parameters.Add("pnaviera", pnaviera)
          oraCommandDocumentos.Parameters.Add("pmuelle_Origen", pmuelle_Origen)
          oraCommandDocumentos.Parameters.Add("pmuelle_Destino", pmuelle_Destino)
          oraCommandDocumentos.Parameters.Add("pemp_Lanchas", pemp_Lanchas)
          oraCommandDocumentos.Parameters.Add("pnum_Lanchas", pnum_Lanchas)
          oraCommandDocumentos.Parameters.Add("ppuerto_Reg", ppuerto_Reg)
          oraCommandDocumentos.Parameters.Add("pcodigo_Llamada", pcodigo_Llamada)
          oraCommandDocumentos.Parameters.Add("pnum_Oficial", pnum_Oficial)
          oraCommandDocumentos.Parameters.Add("pnum_Omi", pnum_Omi)
          oraCommandDocumentos.Parameters.Add("pcolocacion_Quilla", pcolocacion_Quilla)
          oraCommandDocumentos.Parameters.Add("ppuesto_Marcha", ppuesto_Marcha)
          oraCommandDocumentos.Parameters.Add("pTRB", pTRB)
          oraCommandDocumentos.Parameters.Add("pTRN", pTRN)
          oraCommandDocumentos.Parameters.Add("pconstructores", pconstructores)
          oraCommandDocumentos.Parameters.Add("pclase", pclase)
          oraCommandDocumentos.Parameters.Add("pmotor", pmotor)
          oraCommandDocumentos.Parameters.Add("ppropietarios", ppropietarios)
          oraCommandDocumentos.Parameters.Add("poperador", poperador)
          oraCommandDocumentos.Parameters.Add("ppuntal", ppuntal)
          oraCommandDocumentos.Parameters.Add("peslora_Total", peslora_Total)
          oraCommandDocumentos.Parameters.Add("peslora_Perpendiculares", peslora_Perpendiculares)
          oraCommandDocumentos.Parameters.Add("paltura", paltura)
          oraCommandDocumentos.Parameters.Add("pluz", pluz)
          oraCommandDocumentos.Parameters.Add("ppuerto_Destino", ppuerto_Destino)
          oraCommandDocumentos.Parameters.Add("pemp_Amarradores", pemp_Amarradores)
          oraCommandDocumentos.Parameters.Add("pfolio_Permiso_Entrada", pfolio_Permiso_Entrada)
          oraCommandDocumentos.Parameters.Add("ptipo_Buque", ptipo_Buque)
          oraCommandDocumentos.Parameters.Add("ptipo_Carga", ptipo_Carga)
          oraCommandDocumentos.Parameters.Add("pcodigo_Pbip", pcodigo_Pbip)
          oraCommandDocumentos.Parameters.Add("pcolor_Casco", pcolor_Casco)
          oraCommandDocumentos.Parameters.Add("pemp_Remolcadores", pemp_Remolcadores)
          oraCommandDocumentos.Parameters.Add("pnum_Remolcadores", pnum_Remolcadores)
          oraCommandDocumentos.Parameters.Add("pemp_Pilotos", pemp_Pilotos)
          oraCommandDocumentos.Parameters.Add("pnum_Pilotos", pnum_Pilotos)
          oraCommandDocumentos.Parameters.Add("pnum_Amarradores", pnum_Amarradores)
          oraCommandDocumentos.Parameters.Add("ppeso_Muerto", ppeso_Muerto)
          oraCommandDocumentos.Parameters.Add("pcalado_Construccion", pcalado_Construccion)
          oraCommandDocumentos.Parameters.Add("ptipo_Cabo", ptipo_Cabo)

          oraCommandDocumentos.Parameters.Add("pTransaccion", Oracle.DataAccess.Client.OracleDbType.Byte).Direction = ParameterDirection.Output
          oraCommandDocumentos.Parameters.Add("pMensaje", Oracle.DataAccess.Client.OracleDbType.Varchar2, 200).Direction = ParameterDirection.Output

          oraConnection.Open()
          oraCommandDocumentos.ExecuteNonQuery()
          pTransaccion = CByte(oraCommandDocumentos.Parameters("pTransaccion").Value.ToString())
          mensaje = oraCommandDocumentos.Parameters("pMensaje").Value.ToString()
          oraConnection.Close()
        End Using
      End Using
    Catch ex As Exception
      Throw ex
    End Try
    Return pTransaccion
  End Function
  
  ''' <summary>
  ''' Funcion para consultar un registro de la tabla Capt_PermisoMovimiento
  ''' </summary>
  ''' <param name="pNidDocumento">numero de documento</param>
  ''' <returns>DataTable</returns>
  ''' <remarks></remarks>
  Public Function Capt_PermisoMovimiento_Consultar(pNidDocumento As Long) As DataTable
    Dim dtResultado As New DataTable("Capt_PermisoMovimientoConsulta")
    Try
      Using oraConnection As New Oracle.DataAccess.Client.OracleConnection(ConfigurationManager.ConnectionStrings("EDIV2DESOraClient").ConnectionString)
        Using oraCommandDocumentos As New Oracle.DataAccess.Client.OracleCommand()
          oraCommandDocumentos.Connection = oraConnection
          oraCommandDocumentos.CommandTimeout = consTimeOut
          oraCommandDocumentos.CommandType = CommandType.StoredProcedure
          oraCommandDocumentos.CommandText = "EDIV2.?NomPaquete.Capt_PermisoMovimientoConsultar" 
          oraCommandDocumentos.Parameters.Add("pNidDocumento", pNidDocumento)
          oraCommandDocumentos.Parameters.Add("pTransaccion", Oracle.DataAccess.Client.OracleDbType.Byte).Direction = ParameterDirection.Output
          oraCommandDocumentos.Parameters.Add(New Oracle.DataAccess.Client.OracleParameter("pCursor", OracleDbType.RefCursor)).Direction = ParameterDirection.Output

          Dim oraDataAdapter As New OracleDataAdapter(oraCommandDocumentos)
          oraDataAdapter.Fill(dtResultado)
          oraConnection.Close()
        End Using
      End Using
    Catch ex As Exception
      Throw ex
    End Try
    Return dtResultado
  End Function
  
  ''' <summary>
  ''' Funcion para generar la cadena XML Chilkat del documento de la tabla Capt_PermisoMovimiento
  ''' </summary>
  ''' <param name="nidDocumento"> numero del documento</param>
  ''' <returns>Chilkat.Xml</returns>
  ''' <remarks></remarks>
  Public Function Capt_PermisoMovimiento_CadenaOriginalXMLChilkat(nidDocumento As Long) As Chilkat.Xml
    Dim detalleDataSet As New DataSet("DatosCapt_PermisoMovimiento")
    Try
      detalleDataSet = Capt_PermisoMovimiento_DetalleXML(nidDocumento)
	  'En esta parte van las tablas obtenidas en la consulta anterior
	  'separadas dependiendo del reporte a crear, ejemplo:
	  detalleDataSet.Tables(0).TableName = "Informacion del Tramite"
      detalleDataSet.Tables(1).TableName = "Datos Capt_PermisoMovimiento"
      detalleDataSet.Tables(2).TableName = "Archivos Anexos"
      detalleDataSet.Tables(3).TableName = "Incidencias"

      Dim xml As New Chilkat.Xml
      xml.LoadXml(detalleDataSet.GetXml())
      Return xml 'detalleDataSet.GetXml()
    Catch ex As Exception
      Throw ex
    End Try
  End Function

  ''' <summary>
  ''' Funcion para consultar el detalle del documento de la tabla Capt_PermisoMovimiento
  ''' </summary>
  ''' <param name="pNidDocumento">numero del documento</param>
  ''' <returns>DataSet</returns>
  ''' <remarks></remarks>
  Public Function Capt_PermisoMovimiento_DetalleXML(pNidDocumento As Long) As DataSet
    Dim dsDetalle As New DataSet("Capt_PermisoMovimientoDetalle")
    Dim pTransaccion As Byte = 0
    Try
      Using oraConnection As New Oracle.DataAccess.Client.OracleConnection(ConfigurationManager.ConnectionStrings("EDIV2DESOraClient").ConnectionString)
        Using oraCommandDocumentos As New Oracle.DataAccess.Client.OracleCommand()
          oraCommandDocumentos.Connection = oraConnection
          oraCommandDocumentos.CommandTimeout = consTimeOut
          oraCommandDocumentos.CommandType = CommandType.StoredProcedure
          oraCommandDocumentos.CommandText = "EDIV2.?NomPaquete.Capt_PermisoMovimientoDetalleXML"
          oraCommandDocumentos.Parameters.Add("pNidDocumento", pNidDocumento)
          oraCommandDocumentos.Parameters.Add("pTransaccion", Oracle.DataAccess.Client.OracleDbType.Byte).Direction = ParameterDirection.Output
          'En esta parte es para los cursores necesario 
		  oraCommandDocumentos.Parameters.Add(New Oracle.DataAccess.Client.OracleParameter("pEncabezado", OracleDbType.RefCursor)).Direction = ParameterDirection.Output
          oraCommandDocumentos.Parameters.Add(New Oracle.DataAccess.Client.OracleParameter("pDatos", OracleDbType.RefCursor)).Direction = ParameterDirection.Output
          oraCommandDocumentos.Parameters.Add(New Oracle.DataAccess.Client.OracleParameter("pAnexos", OracleDbType.RefCursor)).Direction = ParameterDirection.Output
          oraCommandDocumentos.Parameters.Add(New Oracle.DataAccess.Client.OracleParameter("pIncidencias", OracleDbType.RefCursor)).Direction = ParameterDirection.Output
		
          Dim oraDataAdapter As New OracleDataAdapter(oraCommandDocumentos)
          'pTransaccion = CByte(oraCommandDocumentos.Parameters("pTransaccion").Value.ToString())
          oraDataAdapter.Fill(dsDetalle)
        End Using
      End Using
    Catch ex As Exception
      Throw ex
    End Try
    Return dsDetalle
  End Function
  
  Public Function Capt_PermisoMovimiento_DatosBase() As DataTable
    Dim dtResultado As New DataTable("Capt_PermisoMovimientoConsulta")
    Try
      Using oraConnection As New Oracle.DataAccess.Client.OracleConnection(ConfigurationManager.ConnectionStrings("EDIV2DESOraClient").ConnectionString)
        Using oraCommandDocumentos As New Oracle.DataAccess.Client.OracleCommand()
          oraCommandDocumentos.Connection = oraConnection
          oraCommandDocumentos.CommandTimeout = consTimeOut
          oraCommandDocumentos.CommandType = CommandType.StoredProcedure
          oraCommandDocumentos.CommandText = "EDIV2.?NomPaquete.Capt_PermisoMovimientoDatosBase" 
          oraCommandDocumentos.Parameters.Add("pTransaccion", Oracle.DataAccess.Client.OracleDbType.Byte).Direction = ParameterDirection.Output
          oraCommandDocumentos.Parameters.Add(New Oracle.DataAccess.Client.OracleParameter("pCursor", OracleDbType.RefCursor)).Direction = ParameterDirection.Output

          Dim oraDataAdapter As New OracleDataAdapter(oraCommandDocumentos)
          oraDataAdapter.Fill(dtResultado)
          oraConnection.Close()
        End Using
      End Using
    Catch ex As Exception
      Throw ex
    End Try
    Return dtResultado
  End Function
  
  ''' <summary>
  ''' Funcion para Insertar un regristro en la tabla Capt_PermisoMovimiento
  ''' </summary>
  Public Function Capt_PermisoMovimiento_Insertar(pnidDocumento As Long, pnidAvisoArribo As Long, pnidBuque As Long, pbandera As String, ppuerto_registro As String, ptoneladas_Brutas As Long, ptoneladas_Netas As Long, pcapitan As String, ppuerto_procedencia As String, pdes_movimiento As String, pIMO As String, peslora As Long, pmanga As Long, pcalado_Proa As Long, pcalado_Popa As Long, pfecha_Movimiento As Date, pnombre_Buque As String, pnaviera As String, pmuelle_Origen As String, pmuelle_Destino As String, pemp_Lanchas As String, pnum_Lanchas As Long, ppuerto_Reg As String, pcodigo_Llamada As String, pnum_Oficial As Integer, pnum_Omi As Integer, pcolocacion_Quilla As Integer, ppuesto_Marcha As Integer, pTRB As Long, pTRN As Long, pconstructores As String, pclase As String, pmotor As String, ppropietarios As String, poperador As String, ppuntal As Long, peslora_Total As Long, peslora_Perpendiculares As Long, paltura As Long, pluz As Long, ppuerto_Destino As String, pemp_Amarradores As String, pfolio_Permiso_Entrada As String, ptipo_Buque As String, ptipo_Carga As String, pcodigo_Pbip As String, pcolor_Casco As String, pemp_Remolcadores As String, pnum_Remolcadores As Integer, pemp_Pilotos As String, pnum_Pilotos As Integer, pnum_Amarradores As Integer, ppeso_Muerto As Long, pcalado_Construccion As Long, ptipo_Cabo As String) As Byte
    Dim pTransaccion As Byte = 0
    Dim mensaje As String = String.Empty
    Try
      Using oraConnection As New Oracle.DataAccess.Client.OracleConnection(ConfigurationManager.ConnectionStrings("EDIV2DESOraClient").ConnectionString)
        Using oraCommandDocumentos As New Oracle.DataAccess.Client.OracleCommand()
          oraCommandDocumentos.Connection = oraConnection
          oraCommandDocumentos.CommandTimeout = consTimeOut
          oraCommandDocumentos.CommandType = CommandType.StoredProcedure
          oraCommandDocumentos.CommandText = "EDIV2.?NomPaquete.Capt_PermisoMovimientoInsertar" 
          oraCommandDocumentos.Parameters.Add("pnidDocumento", pnidDocumento)
          oraCommandDocumentos.Parameters.Add("pnidAvisoArribo", pnidAvisoArribo)
          oraCommandDocumentos.Parameters.Add("pnidBuque", pnidBuque)
          oraCommandDocumentos.Parameters.Add("pbandera", pbandera)
          oraCommandDocumentos.Parameters.Add("ppuerto_registro", ppuerto_registro)
          oraCommandDocumentos.Parameters.Add("ptoneladas_Brutas", ptoneladas_Brutas)
          oraCommandDocumentos.Parameters.Add("ptoneladas_Netas", ptoneladas_Netas)
          oraCommandDocumentos.Parameters.Add("pcapitan", pcapitan)
          oraCommandDocumentos.Parameters.Add("ppuerto_procedencia", ppuerto_procedencia)
          oraCommandDocumentos.Parameters.Add("pdes_movimiento", pdes_movimiento)
          oraCommandDocumentos.Parameters.Add("pIMO", pIMO)
          oraCommandDocumentos.Parameters.Add("peslora", peslora)
          oraCommandDocumentos.Parameters.Add("pmanga", pmanga)
          oraCommandDocumentos.Parameters.Add("pcalado_Proa", pcalado_Proa)
          oraCommandDocumentos.Parameters.Add("pcalado_Popa", pcalado_Popa)
          oraCommandDocumentos.Parameters.Add("pfecha_Movimiento", pfecha_Movimiento)
          oraCommandDocumentos.Parameters.Add("pnombre_Buque", pnombre_Buque)
          oraCommandDocumentos.Parameters.Add("pnaviera", pnaviera)
          oraCommandDocumentos.Parameters.Add("pmuelle_Origen", pmuelle_Origen)
          oraCommandDocumentos.Parameters.Add("pmuelle_Destino", pmuelle_Destino)
          oraCommandDocumentos.Parameters.Add("pemp_Lanchas", pemp_Lanchas)
          oraCommandDocumentos.Parameters.Add("pnum_Lanchas", pnum_Lanchas)
          oraCommandDocumentos.Parameters.Add("ppuerto_Reg", ppuerto_Reg)
          oraCommandDocumentos.Parameters.Add("pcodigo_Llamada", pcodigo_Llamada)
          oraCommandDocumentos.Parameters.Add("pnum_Oficial", pnum_Oficial)
          oraCommandDocumentos.Parameters.Add("pnum_Omi", pnum_Omi)
          oraCommandDocumentos.Parameters.Add("pcolocacion_Quilla", pcolocacion_Quilla)
          oraCommandDocumentos.Parameters.Add("ppuesto_Marcha", ppuesto_Marcha)
          oraCommandDocumentos.Parameters.Add("pTRB", pTRB)
          oraCommandDocumentos.Parameters.Add("pTRN", pTRN)
          oraCommandDocumentos.Parameters.Add("pconstructores", pconstructores)
          oraCommandDocumentos.Parameters.Add("pclase", pclase)
          oraCommandDocumentos.Parameters.Add("pmotor", pmotor)
          oraCommandDocumentos.Parameters.Add("ppropietarios", ppropietarios)
          oraCommandDocumentos.Parameters.Add("poperador", poperador)
          oraCommandDocumentos.Parameters.Add("ppuntal", ppuntal)
          oraCommandDocumentos.Parameters.Add("peslora_Total", peslora_Total)
          oraCommandDocumentos.Parameters.Add("peslora_Perpendiculares", peslora_Perpendiculares)
          oraCommandDocumentos.Parameters.Add("paltura", paltura)
          oraCommandDocumentos.Parameters.Add("pluz", pluz)
          oraCommandDocumentos.Parameters.Add("ppuerto_Destino", ppuerto_Destino)
          oraCommandDocumentos.Parameters.Add("pemp_Amarradores", pemp_Amarradores)
          oraCommandDocumentos.Parameters.Add("pfolio_Permiso_Entrada", pfolio_Permiso_Entrada)
          oraCommandDocumentos.Parameters.Add("ptipo_Buque", ptipo_Buque)
          oraCommandDocumentos.Parameters.Add("ptipo_Carga", ptipo_Carga)
          oraCommandDocumentos.Parameters.Add("pcodigo_Pbip", pcodigo_Pbip)
          oraCommandDocumentos.Parameters.Add("pcolor_Casco", pcolor_Casco)
          oraCommandDocumentos.Parameters.Add("pemp_Remolcadores", pemp_Remolcadores)
          oraCommandDocumentos.Parameters.Add("pnum_Remolcadores", pnum_Remolcadores)
          oraCommandDocumentos.Parameters.Add("pemp_Pilotos", pemp_Pilotos)
          oraCommandDocumentos.Parameters.Add("pnum_Pilotos", pnum_Pilotos)
          oraCommandDocumentos.Parameters.Add("pnum_Amarradores", pnum_Amarradores)
          oraCommandDocumentos.Parameters.Add("ppeso_Muerto", ppeso_Muerto)
          oraCommandDocumentos.Parameters.Add("pcalado_Construccion", pcalado_Construccion)
          oraCommandDocumentos.Parameters.Add("ptipo_Cabo", ptipo_Cabo)

          oraCommandDocumentos.Parameters.Add("pTransaccion", Oracle.DataAccess.Client.OracleDbType.Byte).Direction = ParameterDirection.Output
          oraCommandDocumentos.Parameters.Add("pMensaje", Oracle.DataAccess.Client.OracleDbType.Varchar2, 200).Direction = ParameterDirection.Output

          oraConnection.Open()
          oraCommandDocumentos.ExecuteNonQuery()
          pTransaccion = CByte(oraCommandDocumentos.Parameters("pTransaccion").Value.ToString())
          mensaje = oraCommandDocumentos.Parameters("pMensaje").Value.ToString()
          oraConnection.Close()
        End Using
      End Using
    Catch ex As Exception
      Throw ex
    End Try
    Return pTransaccion
  End Function

  ''' <summary>
  ''' Funcion para Modificar un regristro en la tabla Capt_PermisoMovimiento
  ''' </summary>
  Public Function Capt_PermisoMovimiento_Modificar(pnidDocumento As Long, pnidAvisoArribo As Long, pnidBuque As Long, pbandera As String, ppuerto_registro As String, ptoneladas_Brutas As Long, ptoneladas_Netas As Long, pcapitan As String, ppuerto_procedencia As String, pdes_movimiento As String, pIMO As String, peslora As Long, pmanga As Long, pcalado_Proa As Long, pcalado_Popa As Long, pfecha_Movimiento As Date, pnombre_Buque As String, pnaviera As String, pmuelle_Origen As String, pmuelle_Destino As String, pemp_Lanchas As String, pnum_Lanchas As Long, ppuerto_Reg As String, pcodigo_Llamada As String, pnum_Oficial As Integer, pnum_Omi As Integer, pcolocacion_Quilla As Integer, ppuesto_Marcha As Integer, pTRB As Long, pTRN As Long, pconstructores As String, pclase As String, pmotor As String, ppropietarios As String, poperador As String, ppuntal As Long, peslora_Total As Long, peslora_Perpendiculares As Long, paltura As Long, pluz As Long, ppuerto_Destino As String, pemp_Amarradores As String, pfolio_Permiso_Entrada As String, ptipo_Buque As String, ptipo_Carga As String, pcodigo_Pbip As String, pcolor_Casco As String, pemp_Remolcadores As String, pnum_Remolcadores As Integer, pemp_Pilotos As String, pnum_Pilotos As Integer, pnum_Amarradores As Integer, ppeso_Muerto As Long, pcalado_Construccion As Long, ptipo_Cabo As String) As Byte
    Dim pTransaccion As Byte = 0
    Dim mensaje As String = String.Empty
    Try
      Using oraConnection As New Oracle.DataAccess.Client.OracleConnection(ConfigurationManager.ConnectionStrings("EDIV2DESOraClient").ConnectionString)
        Using oraCommandDocumentos As New Oracle.DataAccess.Client.OracleCommand()
          oraCommandDocumentos.Connection = oraConnection
          oraCommandDocumentos.CommandTimeout = consTimeOut
          oraCommandDocumentos.CommandType = CommandType.StoredProcedure
          oraCommandDocumentos.CommandText = "EDIV2.?NomPaquete.Capt_PermisoMovimientoModificar"
          oraCommandDocumentos.Parameters.Add("pnidDocumento", pnidDocumento)
          oraCommandDocumentos.Parameters.Add("pnidAvisoArribo", pnidAvisoArribo)
          oraCommandDocumentos.Parameters.Add("pnidBuque", pnidBuque)
          oraCommandDocumentos.Parameters.Add("pbandera", pbandera)
          oraCommandDocumentos.Parameters.Add("ppuerto_registro", ppuerto_registro)
          oraCommandDocumentos.Parameters.Add("ptoneladas_Brutas", ptoneladas_Brutas)
          oraCommandDocumentos.Parameters.Add("ptoneladas_Netas", ptoneladas_Netas)
          oraCommandDocumentos.Parameters.Add("pcapitan", pcapitan)
          oraCommandDocumentos.Parameters.Add("ppuerto_procedencia", ppuerto_procedencia)
          oraCommandDocumentos.Parameters.Add("pdes_movimiento", pdes_movimiento)
          oraCommandDocumentos.Parameters.Add("pIMO", pIMO)
          oraCommandDocumentos.Parameters.Add("peslora", peslora)
          oraCommandDocumentos.Parameters.Add("pmanga", pmanga)
          oraCommandDocumentos.Parameters.Add("pcalado_Proa", pcalado_Proa)
          oraCommandDocumentos.Parameters.Add("pcalado_Popa", pcalado_Popa)
          oraCommandDocumentos.Parameters.Add("pfecha_Movimiento", pfecha_Movimiento)
          oraCommandDocumentos.Parameters.Add("pnombre_Buque", pnombre_Buque)
          oraCommandDocumentos.Parameters.Add("pnaviera", pnaviera)
          oraCommandDocumentos.Parameters.Add("pmuelle_Origen", pmuelle_Origen)
          oraCommandDocumentos.Parameters.Add("pmuelle_Destino", pmuelle_Destino)
          oraCommandDocumentos.Parameters.Add("pemp_Lanchas", pemp_Lanchas)
          oraCommandDocumentos.Parameters.Add("pnum_Lanchas", pnum_Lanchas)
          oraCommandDocumentos.Parameters.Add("ppuerto_Reg", ppuerto_Reg)
          oraCommandDocumentos.Parameters.Add("pcodigo_Llamada", pcodigo_Llamada)
          oraCommandDocumentos.Parameters.Add("pnum_Oficial", pnum_Oficial)
          oraCommandDocumentos.Parameters.Add("pnum_Omi", pnum_Omi)
          oraCommandDocumentos.Parameters.Add("pcolocacion_Quilla", pcolocacion_Quilla)
          oraCommandDocumentos.Parameters.Add("ppuesto_Marcha", ppuesto_Marcha)
          oraCommandDocumentos.Parameters.Add("pTRB", pTRB)
          oraCommandDocumentos.Parameters.Add("pTRN", pTRN)
          oraCommandDocumentos.Parameters.Add("pconstructores", pconstructores)
          oraCommandDocumentos.Parameters.Add("pclase", pclase)
          oraCommandDocumentos.Parameters.Add("pmotor", pmotor)
          oraCommandDocumentos.Parameters.Add("ppropietarios", ppropietarios)
          oraCommandDocumentos.Parameters.Add("poperador", poperador)
          oraCommandDocumentos.Parameters.Add("ppuntal", ppuntal)
          oraCommandDocumentos.Parameters.Add("peslora_Total", peslora_Total)
          oraCommandDocumentos.Parameters.Add("peslora_Perpendiculares", peslora_Perpendiculares)
          oraCommandDocumentos.Parameters.Add("paltura", paltura)
          oraCommandDocumentos.Parameters.Add("pluz", pluz)
          oraCommandDocumentos.Parameters.Add("ppuerto_Destino", ppuerto_Destino)
          oraCommandDocumentos.Parameters.Add("pemp_Amarradores", pemp_Amarradores)
          oraCommandDocumentos.Parameters.Add("pfolio_Permiso_Entrada", pfolio_Permiso_Entrada)
          oraCommandDocumentos.Parameters.Add("ptipo_Buque", ptipo_Buque)
          oraCommandDocumentos.Parameters.Add("ptipo_Carga", ptipo_Carga)
          oraCommandDocumentos.Parameters.Add("pcodigo_Pbip", pcodigo_Pbip)
          oraCommandDocumentos.Parameters.Add("pcolor_Casco", pcolor_Casco)
          oraCommandDocumentos.Parameters.Add("pemp_Remolcadores", pemp_Remolcadores)
          oraCommandDocumentos.Parameters.Add("pnum_Remolcadores", pnum_Remolcadores)
          oraCommandDocumentos.Parameters.Add("pemp_Pilotos", pemp_Pilotos)
          oraCommandDocumentos.Parameters.Add("pnum_Pilotos", pnum_Pilotos)
          oraCommandDocumentos.Parameters.Add("pnum_Amarradores", pnum_Amarradores)
          oraCommandDocumentos.Parameters.Add("ppeso_Muerto", ppeso_Muerto)
          oraCommandDocumentos.Parameters.Add("pcalado_Construccion", pcalado_Construccion)
          oraCommandDocumentos.Parameters.Add("ptipo_Cabo", ptipo_Cabo)

          oraCommandDocumentos.Parameters.Add("pTransaccion", Oracle.DataAccess.Client.OracleDbType.Byte).Direction = ParameterDirection.Output
          oraCommandDocumentos.Parameters.Add("pMensaje", Oracle.DataAccess.Client.OracleDbType.Varchar2, 200).Direction = ParameterDirection.Output

          oraConnection.Open()
          oraCommandDocumentos.ExecuteNonQuery()
          pTransaccion = CByte(oraCommandDocumentos.Parameters("pTransaccion").Value.ToString())
          mensaje = oraCommandDocumentos.Parameters("pMensaje").Value.ToString()
          oraConnection.Close()
        End Using
      End Using
    Catch ex As Exception
      Throw ex
    End Try
    Return pTransaccion
  End Function
  
  ''' <summary>
  ''' Funcion para generar un combo de la tabla Capt_PermisoMovimiento
  ''' </summary>
  ''' <param name="pNombre">nombre a buscar en la tabla</param>
  ''' <returns>DataTable</returns>
  ''' <remarks>si el nombre es "" retornara todos los registros</remarks>
  Public Function Capt_PermisoMovimiento_Combo(pNombre As String) As DataTable
    Dim dtResultado As New DataTable("Capt_PermisoMovimientoCombo")
    Try
      Using oraConnection As New Oracle.DataAccess.Client.OracleConnection(ConfigurationManager.ConnectionStrings("EDIV2DESOraClient").ConnectionString)
        Using oraCommandDocumentos As New Oracle.DataAccess.Client.OracleCommand()
          oraCommandDocumentos.Connection = oraConnection
          oraCommandDocumentos.CommandTimeout = consTimeOut
          oraCommandDocumentos.CommandType = CommandType.StoredProcedure
          oraCommandDocumentos.CommandText = "EDIV2.?NomPaquete.Capt_PermisoMovimientoCombo" 
		  oraCommandDocumentos.Parameters.Add("pNombre", pNombre)
          oraCommandDocumentos.Parameters.Add("pTransaccion", Oracle.DataAccess.Client.OracleDbType.Byte).Direction = ParameterDirection.Output
          oraCommandDocumentos.Parameters.Add(New Oracle.DataAccess.Client.OracleParameter("pCursor", OracleDbType.RefCursor)).Direction = ParameterDirection.Output

          Dim oraDataAdapter As New OracleDataAdapter(oraCommandDocumentos)
          oraDataAdapter.Fill(dtResultado)
          oraConnection.Close()
        End Using
      End Using
    Catch ex As Exception
      Throw ex
    End Try
    Return dtResultado
  End Function
  
  ''' <summary>
  ''' Funcion para generar la integracion del documento de la tabla Capt_PermisoMovimiento
  ''' </summary>
  ''' <param name="pNidDocumento">numero del documento</param>
  ''' <returns>Byte</returns>
  ''' <remarks></remarks>
  Public Function Capt_PermisoMovimiento_Integracion(pNidDocumento As Long) As Byte
    Dim pTransaccion As Byte = 0
    Dim mensaje As String = String.Empty
    Try
      Using oraConnection As New Oracle.DataAccess.Client.OracleConnection(ConfigurationManager.ConnectionStrings("EDIV2DESOraClient").ConnectionString)
        Using oraCommandDocumentos As New Oracle.DataAccess.Client.OracleCommand()
          oraCommandDocumentos.Connection = oraConnection
          oraCommandDocumentos.CommandTimeout = consTimeOut
          oraCommandDocumentos.CommandType = CommandType.StoredProcedure
          oraCommandDocumentos.CommandText = "EDIV2.?NomPaquete.Capt_PermisoMovimientoIntegracion"
          oraCommandDocumentos.Parameters.Add("pNidDocumento", pNidDocumento)
          oraCommandDocumentos.Parameters.Add("pTransaccion", Oracle.DataAccess.Client.OracleDbType.Byte).Direction = ParameterDirection.Output
          oraCommandDocumentos.Parameters.Add("pMensaje", Oracle.DataAccess.Client.OracleDbType.Varchar2, 200).Direction = ParameterDirection.Output

          oraConnection.Open()
          oraCommandDocumentos.ExecuteNonQuery()
          pTransaccion = CByte(oraCommandDocumentos.Parameters("pTransaccion").Value.ToString())
          mensaje = oraCommandDocumentos.Parameters("pMensaje").Value.ToString()
          oraConnection.Close()
        End Using
      End Using
    Catch ex As Exception
      Throw ex
    End Try
    Return pTransaccion
  End Function
  
  Public Function Capt_PermisoMovimiento_Borrar(pnid As Long) As Byte
    Dim pTransaccion As Byte = 0
    Dim mensaje As String = String.Empty
    Try
      Using oraConnection As New Oracle.DataAccess.Client.OracleConnection(ConfigurationManager.ConnectionStrings("EDIV2DESOraClient").ConnectionString)
        Using oraCommandDocumentos As New Oracle.DataAccess.Client.OracleCommand()
          oraCommandDocumentos.Connection = oraConnection
          oraCommandDocumentos.CommandTimeout = consTimeOut
          oraCommandDocumentos.CommandType = CommandType.StoredProcedure
          oraCommandDocumentos.CommandText = "EDIV2.?NomPaquete.Capt_PermisoMovimientoBorrar"
          oraCommandDocumentos.Parameters.Add("pnid", pnid)
          oraCommandDocumentos.Parameters.Add("pTransaccion", Oracle.DataAccess.Client.OracleDbType.Byte).Direction = ParameterDirection.Output
          
          oraConnection.Open()
          oraCommandDocumentos.ExecuteNonQuery()
          pTransaccion = CByte(oraCommandDocumentos.Parameters("pTransaccion").Value.ToString())
          oraConnection.Close()
        End Using
      End Using
    Catch ex As Exception
      Throw ex
    End Try
    Return pTransaccion
  End Function
  
  
End Class
